package mil.af.amc.adpetracker.model;

import javax.persistence.*;
import java.io.Serializable;

/**
 * Please Fill in this Javadoc
 *
 * @author TSgt Jason Ferguson
 */

@Entity
@Table(name="T_ACCT_ADPEACCT")
//@ForeignKey(name="AAA", inverseName = "AAA")
public class AccountAdpeAccount implements Serializable {

    private int id;
    private Account account;
    private AdpeAccount adpeAccount;
    private Authority authority;

    public AccountAdpeAccount(Account account, AdpeAccount adpeAccount) {
        this.account = account;
        this.adpeAccount = adpeAccount;
    }

    public AccountAdpeAccount() {

    }

    @Id
    @Column(name="ID")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @ManyToOne
    //@JoinColumn(name="ACCOUNT_ID")
    @JoinColumn(name="ACCTID")
    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    @ManyToOne
    @JoinColumn(name="ADPEACCTID")
    public AdpeAccount getAdpeAccount() {
        return adpeAccount;
    }

    public void setAdpeAccount(AdpeAccount adpeAccount) {
        this.adpeAccount = adpeAccount;
    }

    @ManyToOne
    @JoinColumn(name="AUTHORITYID")
    public Authority getAuthority() {
        return authority;
    }

    public void setAuthority(Authority authority) {
        this.authority = authority;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        final AccountAdpeAccount that = (AccountAdpeAccount) o;

        if (account != null ? !account.equals(that.account) : that.account != null) return false;
        if (adpeAccount != null ? !adpeAccount.equals(that.adpeAccount) : that.adpeAccount != null) return false;

        return true;
    }

    public int hashCode() {
        int result;
        result = (account != null ? account.hashCode() : 0);
        result = 29 * result + (adpeAccount != null ? adpeAccount.hashCode() : 0);
        return result;
    }
}
